<template>
  <div class="authority">
    <!-- <div class="gva-search-box">
      <el-form ref="searchForm" :inline="true">
        <el-form-item label="昵称">
          <el-input v-model="searchInfo.nickName" placeholder="请输入" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="search" @click="onSubmit">
            查询
          </el-button>
          <el-button icon="refresh" @click="onReset">重置</el-button>
        </el-form-item>
      </el-form>
    </div> -->
    <div class="gva-table-box unit">
      <div class="gva-btn-list">
        <el-button type="primary" icon="plus" @click="register">新增</el-button>
      </div>
      <el-table :data="tableData" row-key="id">
        <el-table-column type="index" label="序号" width="60" />
        <el-table-column align="left" label="小程序名称" width="130" prop="miniName" show-overflow-tooltip></el-table-column>
        <el-table-column align="left" label="小程序头像" width="130">
          <template #default="scope">
            <img v-if="scope.row.miniHeader" :src="scope.row.miniHeader"
              style="width: 50px;height:50px;border-radius: 50%;">
            <img v-else src="@/assets/noBody.png" style="width: 50px;height:50px;border-radius: 50%;">
          </template>
        </el-table-column>
        <el-table-column align="left" label="appId" prop="appId" show-overflow-tooltip></el-table-column>
        <el-table-column align="left" label="注册状态" width="130" show-overflow-tooltip>
          <template #default="scope">
            {{ scope.row.registerStatus == '0' ? '正常' : '等待法人提交信息' }}
          </template>
        </el-table-column>
        <el-table-column align="left" label="发布状态" width="130" show-overflow-tooltip>
          <template #default="scope">
            {{ getStatus(scope.row.miniStatus) }}
          </template>
        </el-table-column>
        <el-table-column align="left" label="企业名" prop="name" show-overflow-tooltip></el-table-column>
        <el-table-column align="left" label="第三方联系电话" width="130" prop="componentPhone"
          show-overflow-tooltip></el-table-column>
        <el-table-column align="left" label="法人姓名" prop="legalPersonaName" show-overflow-tooltip></el-table-column>
        <el-table-column align="left" label="法人微信号" width="130" prop="legalPersonaWechat"
          show-overflow-tooltip></el-table-column>
        <el-table-column align="left" label="企业代码类型" width="130" show-overflow-tooltip>
          <template #default="scope">
            {{ getType(scope.row.codeType) }}
          </template>
        </el-table-column>
        <el-table-column align="left" label="组织机构代码证或营业执照" width="200" show-overflow-tooltip>
          <template #default="scope">
            <img v-if="scope.row.license" :src="scope.row.license" style="width: 50px;height:50px;border-radius: 50%;">
            <img v-else src="@/assets/noBody.png" style="width: 50px;height:50px;border-radius: 50%;">
          </template>
        </el-table-column>
        <el-table-column align="left" fixed="right" label="操作" min-width="300">
          <template #default="scope">
            <el-button v-if="scope.row.registerStatus == '0'" type="primary" link @click="setting(scope.row)">
              设置
            </el-button>
            <el-button v-if="scope.row.registerStatus == '0'" type="primary" link @click="commit(scope.row)">
              版本
            </el-button>
            <el-button v-if="scope.row.appId" type="primary" link @click="auth(scope.row)">
              认证
            </el-button>
            <el-button v-if="scope.row.appId" type="primary" link @click="seeProce(scope.row)">
              认证进度
            </el-button>
            <el-button v-if="scope.row.appId" type="primary" link @click="ba(scope.row)">
              备案
            </el-button>
            <el-button v-if="scope.row.appId" style="margin-left:0px" type="primary" link @click="baProce(scope.row)">
              备案进度
            </el-button>
            <el-button type="primary" link @click="edit(scope.row)">
              编辑
            </el-button>
            <el-button type="danger" link @click="del(scope.row)">
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="gva-pagination">
        <el-pagination v-model:current-page="page" :page-size="pageSize" :total="total" layout="prev, pager, next"
          @current-change="handleCurrentChange" />
      </div>
    </div>
    <el-drawer v-model="dialogFormVisible" :size="1000" :before-close="handleClose" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">{{ title }}</span>
          <div>
            <el-button @click="closeDialog">取消</el-button>
            <el-button type="primary" @click="enterDialog">确定</el-button>
          </div>
        </div>
      </template>
      <el-form v-if="dialogFormVisible" ref="yyglForm" label-width="190" :model="form" :rules="rules">
        <el-form-item label="企业代码" prop="code">
          <el-input v-model="form.code" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="企业代码类型" prop="codeType">
          <el-radio-group v-model.number="form.codeType" class="ml-4">
            <el-radio :value="1" size="large">统一社会信用代码（18 位）</el-radio>
            <el-radio :value="2" size="large">组织机构代码（9 位 xxxxxxxx-x）</el-radio>
            <el-radio :value="3" size="large">营业执照注册号(15 位)</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="第三方联系电话" prop="componentPhone">
          <el-input v-model="form.componentPhone" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="法人姓名" prop="legalPersonaName">
          <el-input v-model="form.legalPersonaName" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="法人微信号" prop="legalPersonaWechat">
          <el-input v-model="form.legalPersonaWechat" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="企业名" prop="name">
          <el-input v-model="form.name" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="组织机构代码证或营业执照" prop="license">
          <el-upload v-model:file-list="fileList5" action="" :http-request="upload5" list-type="picture-card"
            :on-preview="handlePicturePreview">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
          <el-dialog v-model="dialogVisible">
            <img w-full :src="dialogImageUrl" alt="Preview Image" />
          </el-dialog>
        </el-form-item>
      </el-form>
    </el-drawer>
    <el-drawer v-model="commitDialog" :size="1000" :before-close="handleClose1" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg"></span>
          <div>
            <el-button @click="commitDialog = false">取消</el-button>
            <el-button type="primary" @click="enterDialog1">确定</el-button>
          </div>
        </div>
      </template>
      <el-steps :space="300" :active="commitForm.progress" finish-status="success" align-center style="margin: 30px 0;">
        <el-step @click.native="changeProgress(0)">
          <template #title>
            <span style="cursor: pointer;">上传代码并生成体验版</span>
          </template>
        </el-step>
        <el-step @click.native="changeProgress(1)">
          <template #title>
            <span style="cursor: pointer;">提交审核</span>
          </template>
        </el-step>
        <el-step @click.native="changeProgress(2)">
          <template #title>
            <span style="cursor: pointer;">发布</span>
          </template>
        </el-step>
      </el-steps>
      <el-form v-if="commitDialog" label-width="150">
        <template #header>
          <div class="flex justify-between items-center">
            <span class="text-lg">鱼池钓位</span>
            <div>
              <el-button @click="commitDialog = false">取消</el-button>
            </div>
          </div>
        </template>
        <el-table v-if="commitForm.progress == 0" :data="commitData" class="table-style" ref="multipleTable"
          row-key="template_id" @select="selectInfo">
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column type="index" label="序号" width="100" />
          <el-table-column align="left" label="提交人" prop="developer"></el-table-column>
          <el-table-column align="left" label="小程序名称" prop="source_miniprogram"></el-table-column>
          <el-table-column align="left" label="版本描述" width="340" prop="user_desc"></el-table-column>
          <el-table-column align="left" label="版本号" prop="user_version"></el-table-column>
        </el-table>
        <el-form-item label="类目" prop="code" v-if="commitForm.progress == 1">
          <el-cascader ref="cascader" :options="categoryArr" :props="props" style="width:600px"
            @change="searchAreaChange" />
        </el-form-item>
        <div v-if="commitForm.progress == 1" style="margin: 50px 0 0 100px;">
          <el-button type="primary" @click="shStatus">查询审核单状态</el-button>
        </div>
        <div v-if="commitForm.progress == 2" style="margin: 50px 0 0 130px;">
          <div v-if="versionInfo.exp_info">
            <div class="section-title">体验版信息</div>
            <div class="row">
              <div class="label2">提交体验版的时间:</div>
              <div class="value">{{ formatTimestamps(versionInfo.exp_info.exp_time) }}</div>
            </div>
            <div class="row">
              <div class="label2">体验版版本信息:</div>
              <div class="value">{{ versionInfo.exp_info.exp_version }}</div>
            </div>
            <div class="row">
              <div class="label2">体验版版本描述:</div>
              <div class="value">{{ versionInfo.exp_info.exp_desc }}</div>
            </div>
          </div>
          <div v-if="versionInfo.release_info" style="margin-top: 15px;">
            <div class="section-title">线上版信息</div>
            <div class="row">
              <div class="label2">发布线上版的时间:</div>
              <div class="value">{{ formatTimestamps(versionInfo.release_info.release_time) }}</div>
            </div>
            <div class="row">
              <div class="label2">线上版版本信息:</div>
              <div class="value">{{ versionInfo.release_info.release_version }}</div>
            </div>
            <div class="row">
              <div class="label2">线上版本描述:</div>
              <div class="value">{{ versionInfo.release_info.release_desc }}</div>
            </div>
          </div>

          <el-button type="primary" @click="publish" style="margin-top: 50px;">发布</el-button>
        </div>
      </el-form>
    </el-drawer>
    <el-drawer v-model="weixinVisible" :size="1000" :before-close="handleClose2" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">绑定体验者</span>
          <div>
            <el-button @click="weixinVisible = false">取消</el-button>
            <el-button type="primary" @click="enterDialog2">确定</el-button>
          </div>
        </div>
      </template>
      <el-form v-if="weixinVisible" ref="yyglForm" label-width="190" :model="commitForm" :rules="rules">
        <el-form-item label="微信号" prop="wechatid">
          <el-input v-model="commitForm.wechatid" placeholder="请输入" />
        </el-form-item>
      </el-form>
    </el-drawer>
    <el-drawer v-model="settingVisible" :size="1000" :before-close="handleClose3" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">设置</span>
          <div>
            <el-button @click="closeDialog3">取消</el-button>
          </div>
        </div>
      </template>
      <div style="margin-top: 50px;">
        <el-button type="primary" @click="bindPerson">绑定体验者</el-button>
        <el-button type="primary" @click="getCode">获取体验版二维码</el-button>
        <el-button type="primary" @click="setAvatar">设置小程序头像</el-button>
        <el-button type="primary" @click="setName">设置小程序名称</el-button>
        <el-button type="primary" @click="setDomian">设置服务器域名</el-button>
        <el-button type="primary" @click="addTemplate">将草稿添加到模板库</el-button>
        <el-button type="primary" style="margin: 20px 0 0 0;" @click="bindAccount">绑定开放平台账号</el-button>
        <el-button type="primary" style="margin-top: 20px;" @click="showLm">添加类目</el-button>
        <el-button type="primary" style="margin-top: 20px;" @click="getLink">生成授权链接</el-button>
        <el-button type="primary" style="margin-top: 20px;" @click="setDecs">设置小程序介绍</el-button>
        <el-button type="primary" style="margin-top: 20px;" @click="setPrivacy">设置小程序用户隐私保护指引</el-button>
        <div style="margin-top: 20px;">{{ link }}</div>
      </div>
    </el-drawer>
    <el-dialog v-model="qrcodeVisible">
      <img w-full :src="qrcodeUrl" alt="Preview Image" style="margin: 0 auto;" />
    </el-dialog>
    <el-drawer v-model="avatarVisible" :size="1000" :before-close="handleClose4" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">设置小程序头像</span>
          <div>
            <el-button @click="closeDialog4">取消</el-button>
            <el-button type="primary" @click="enterDialog4">确定</el-button>
          </div>
        </div>
      </template>
      <el-form v-if="avatarVisible" ref="yyglForm" label-width="190" :model="commitForm" :rules="rules">
        <el-form-item label="小程序头像" prop="headImage">
          <el-upload v-model:file-list="fileList4" action="" :http-request="upload4" :on-success="uploadSuccess4"
            list-type="picture-card" :on-preview="handlePicturePreview">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
          <el-dialog v-model="dialogVisible">
            <img w-full :src="dialogImageUrl" alt="Preview Image" />
          </el-dialog>
        </el-form-item>
      </el-form>
    </el-drawer>
    <el-drawer v-model="nameVisible" :size="1000" :before-close="handleClose5" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">设置小程序名称</span>
          <div>
            <el-button @click="closeDialog5">取消</el-button>
            <el-button type="primary" @click="enterDialog5">确定</el-button>
          </div>
        </div>
      </template>
      <el-form v-if="nameVisible" ref="yyglForm" label-width="190" :model="commitForm" :rules="rules">
        <el-form-item label="小程序名称" prop="nickName">
          <el-input v-model="commitForm.nickName" placeholder="请输入" />
        </el-form-item>
      </el-form>
    </el-drawer>
    <el-drawer v-model="domainVisible" :size="1000" :before-close="handleClose6" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">设置服务器域名</span>
          <div>
            <el-button @click="closeDialog6">取消</el-button>
            <el-button type="primary" @click="enterDialog6">确定</el-button>
          </div>
        </div>
      </template>
      <el-form v-if="domainVisible" ref="yyglForm" label-width="190" :model="domainObj" :rules="rules">
        <el-form-item label="操作类型" prop="action">
          <el-radio-group v-model.number="domainObj.action" class="ml-4">
            <el-radio value="add" size="large">add</el-radio>
            <el-radio value="delete" size="large">delete</el-radio>
            <el-radio value="set" size="large">set</el-radio>
            <el-radio value="get" size="large">get</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="downloadFile合法域名" prop="downloadDomain">
          <el-input v-model="domainObj.downloadDomain" placeholder="请输入,多个用;隔开" />
        </el-form-item>
        <el-form-item label="request合法域名" prop="requestDomain">
          <el-input v-model="domainObj.requestDomain" placeholder="请输入,多个用;隔开" />
        </el-form-item>
        <el-form-item label="tcp合法域名" prop="tcpDomain">
          <el-input v-model="domainObj.tcpDomain" placeholder="请输入,多个用;隔开" />
        </el-form-item>
        <el-form-item label="udp合法域名" prop="udpDomain">
          <el-input v-model="domainObj.udpDomain" placeholder="请输入,多个用;隔开" />
        </el-form-item>
        <el-form-item label="uploadFile合法域名" prop="uploadDomain">
          <el-input v-model="domainObj.uploadDomain" placeholder="请输入,多个用;隔开" />
        </el-form-item>
        <el-form-item label="wsRequest合法域名" prop="wsRequestDomain">
          <el-input v-model="domainObj.wsRequestDomain" placeholder="请输入,多个用;隔开" />
        </el-form-item>
      </el-form>
    </el-drawer>
    <el-drawer v-model="mbVisible" :size="1000" :before-close="handleClose8" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">草稿箱列表</span>
          <div>
            <el-button @click="closeDialog8">取消</el-button>
            <el-button type="primary" @click="enterDialog8">确定</el-button>
          </div>
        </div>
      </template>
      <el-table :data="mbData" class="table-style" ref="mbTable" row-key="draft_id" @select="selectMb">
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column type="index" label="序号" width="100" />
        <el-table-column align="left" label="提交人" prop="developer"></el-table-column>
        <el-table-column align="left" label="小程序名称" prop="source_miniprogram"></el-table-column>
        <el-table-column align="left" label="版本描述" width="340" prop="user_desc"></el-table-column>
        <el-table-column align="left" label="版本号" prop="user_version"></el-table-column>
      </el-table>
    </el-drawer>
    <el-drawer v-model="rzVisible" :size="1000" :before-close="handleClose7" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">认证</span>
          <div>
            <el-button @click="closeDialog7">取消</el-button>
            <el-button type="primary" @click="enterDialog7">确定</el-button>
          </div>
        </div>
      </template>
      <el-form v-if="rzVisible" ref="yyglForm" label-width="260" :model="rzForm" :rules="rzRules">
        <el-form-item label="认证联系人姓名" prop="name">
          <el-input v-model="rzForm.name" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="认证联系人邮箱" prop="email">
          <el-input v-model="rzForm.email" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="认证联系人手机号">
          <el-input v-model="rzForm.mobile" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="发票类型" prop="invoice_type">
          <el-radio-group v-model="rzForm.invoice_type" class="ml-4">
            <el-radio :value="1" size="large">不开发票</el-radio>
            <el-radio :value="2" size="large">电子发票</el-radio>
            <el-radio :value="4" size="large">增值税专票（数电类型）</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item v-if="rzForm.invoice_type == 2" label="纳税识别号（15位、17、18或20位）" prop="id1">
          <el-input v-model="rzForm.id1" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="rzForm.invoice_type == 2" label="发票备注（选填）" prop="desc1">
          <el-input v-model="rzForm.desc1" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="rzForm.invoice_type == 4" label="企业电话" prop="enterprise_phone">
          <el-input v-model="rzForm.enterprise_phone" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="rzForm.invoice_type == 4" label="纳税识别号（15位、17、18或20位）" prop="id2">
          <el-input v-model="rzForm.id2" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="rzForm.invoice_type == 4" label="企业注册地址" prop="enterprise_address">
          <el-input v-model="rzForm.enterprise_address" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="rzForm.invoice_type == 4" label="企业银行账号（选填）" prop="bank_account">
          <el-input v-model="rzForm.bank_account" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="rzForm.invoice_type == 4" label="企业开户银行（选填）" prop="bank_name">
          <el-input v-model="rzForm.bank_name" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="rzForm.invoice_type == 4" label="发票备注（选填）" prop="desc2">
          <el-input v-model="rzForm.desc2" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="认证主体类型" prop="customer_type">
          <el-radio-group v-model="rzForm.customer_type" class="ml-4">
            <el-radio :value="1" size="large">企业</el-radio>
            <el-radio :value="12" size="large">个体工商户</el-radio>
            <el-radio :value="15" size="large">个人</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="支付方式" prop="pay_type">
          <el-radio-group v-model="rzForm.pay_type" class="ml-4">
            <el-radio :value="1" size="large">消耗服务商预购包</el-radio>
            <el-radio :value="2" size="large">小程序开发者自行支付</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="账号名称" prop="account_name">
          <el-input v-model="rzForm.account_name" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="rzForm.customer_type != 15" label="主体资质材料" prop="qualification">
          <el-upload v-model:file-list="fileList20" :http-request="upload20" list-type="picture-card"
            :on-preview="handlePicturePreview">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
          <el-dialog v-model="dialogVisible">
            <img w-full :src="dialogImageUrl" alt="Preview Image" />
          </el-dialog>
        </el-form-item>
        <el-form-item label="主体资质其他证明材料" prop="qualification_other">
          <el-upload v-model:file-list="fileList18" multiple :http-request="upload18" list-type="picture-card"
            :on-remove="handleRemove18">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
        </el-form-item>
        <el-form-item label="名称命中关键词-补充材料" prop="account_supplemental">
          <el-upload v-model:file-list="fileList19" multiple :http-request="upload19" list-type="picture-card"
            :on-remove="handleRemove19">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
        </el-form-item>
        <el-form-item label="账号名称命名类型" prop="account_name_type">
          <el-radio-group v-model="rzForm.account_name_type" class="ml-4">
            <el-radio :value="1" size="large">基于自选词汇命名</el-radio>
            <el-radio :value="2" size="large">基于商标命名</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="服务市场 appid" prop="service_appid">
          <el-input v-model="rzForm.service_appid" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="第三方联系电话" prop="third_party_phone">
          <el-input v-model="rzForm.third_party_phone" placeholder="请输入" />
        </el-form-item>
      </el-form>
    </el-drawer>
    <el-drawer v-model="baInfoVisible" :size="1000" :before-close="handleClose9" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">小程序备案进度</span>
          <div>
            <el-button @click="baInfoVisible = false">取消</el-button>
          </div>
        </div>
      </template>
      <div class="row">
        <div class="label">备案状态:</div>
        <div class="value">{{ getProStatus(baInfo.status) }}</div>
      </div>
      <div class="row">
        <div class="label">备案入口是否对该小程序开放:</div>
        <div class="value">{{ baInfo.available == 0 ? '不开放' : '开放' }}</div>
      </div>
      <div class="row" v-if="baInfo.status == 4">
        <div class="label">管局短信核验状态:</div>
        <div class="value">{{ getSmsStatus(baInfo.sms_verify_status) }}</div>
      </div>
      <div class="section-title" v-if="baInfo.procedure_status == 3 || baInfo.procedure_status == 5">驳回原因</div>
      <el-table v-if="baInfo.procedure_status == 23 || baInfo.procedure_status == 25" :data="baInfo.audit_data"
        row-key="key_name" class="table-style">
        <el-table-column type="index" label="序号" width="100" />
        <el-table-column align="left" label="审核不通过的字段中文名" prop="key_name" show-overflow-tooltip></el-table-column>
        <el-table-column align="left" label="字段不通过的原因" width="400" prop="error" show-overflow-tooltip></el-table-column>
        <el-table-column align="left" label="修改建议" prop="suggest" show-overflow-tooltip></el-table-column>
      </el-table>
    </el-drawer>
    <el-drawer v-model="baVisible" :size="1000" :before-close="handleClose10" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">备案</span>
          <div>
            <el-button type="primary" @click="startFace">发起小程序管理员人脸核身</el-button>
            <el-button @click="closeDialog10">取消</el-button>
            <el-button type="primary" @click="enterDialog9">确定</el-button>
          </div>
        </div>
      </template>
      <el-steps :space="300" :active="progress" finish-status="success" align-center style="margin: 30px 0;">
        <el-step @click.native="rzProgress(0)">
          <template #title>
            <span style="cursor: pointer;">备案主体信息</span>
          </template>
        </el-step>
        <el-step @click.native="rzProgress(1)">
          <template #title>
            <span style="cursor: pointer;">微信小程序信息</span>
          </template>
        </el-step>
        <el-step @click.native="rzProgress(2)">
          <template #title>
            <span style="cursor: pointer;">其他备案媒体材料</span>
          </template>
        </el-step>
      </el-steps>
      <el-form v-if="baVisible" ref="yyglForm" label-width="250" :model="baForm" :rules="baRules">
        <el-form-item v-if="progress == 0" label="主体性质" prop="type1">
          <el-radio-group v-model="baForm.type1" class="ml-4">
            <el-radio :value="1" size="large">企业</el-radio>
            <el-radio :value="12" size="large">个体工商户</el-radio>
            <el-radio :value="15" size="large">个人</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item v-if="progress == 0" label="主办单位名称" prop="name1">
          <el-input v-model="baForm.name1" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 0" label="备案区域" prop="areas">
          <el-cascader :options="areaList" popper-class="popper-select" :props="props1" clearable @change="changeArea"
            v-model="baForm.areas" style="width: 100%;" />
        </el-form-item>
        <el-form-item v-if="progress == 0" label="通讯地址" prop="address1">
          <el-input v-model="baForm.address1" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 0" label="主体信息备注" prop="comment1">
          <el-input v-model="baForm.comment1" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 0" label="主体备案号" prop="record_number1">
          <el-input v-model="baForm.record_number1" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 0" prop="certificate_type1" label="主体证件类型">
          <el-select v-model.number="baForm.certificate_type1" placeholder="请选择">
            <el-option v-for="item in certificate_types" :key="item.type" :label="item.name" :value="item.type" />
          </el-select>
        </el-form-item>
        <el-form-item v-if="progress == 0" label="主体证件号码" prop="certificate_number1">
          <el-input v-model="baForm.certificate_number1" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 0" label="主体证件住所" prop="certificate_address1">
          <el-input v-model="baForm.certificate_address1" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-show="progress == 0" label="主体证件照片" prop="certificate_photo1">
          <el-upload v-model:file-list="fileList21" :http-request="upload21" list-type="picture-card"
            :on-preview="handlePicturePreview">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
          <el-dialog v-model="dialogVisible">
            <img w-full :src="dialogImageUrl" alt="Preview Image" />
          </el-dialog>
        </el-form-item>
        <el-form-item v-if="progress == 0" label="负责人姓名" prop="name11">
          <el-input v-model="baForm.name11" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 0" label="负责人联系方式" prop="mobile1">
          <el-input v-model="baForm.mobile1" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 0" label="负责人电子邮件" prop="email1">
          <el-input v-model="baForm.email1" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 0" label="负责人应急联系方式" prop="emergency_contact1">
          <el-input v-model="baForm.emergency_contact1" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 0" label="负责人证件类型" prop="certificate_type11">
          <el-select v-model.number="baForm.certificate_type11" placeholder="请选择">
            <el-option v-for="item in certificate_types" :key="item.type" :label="item.name" :value="item.type" />
          </el-select>
        </el-form-item>
        <el-form-item v-if="progress == 0" label="负责人证件号码" prop="certificate_number11">
          <el-input v-model="baForm.certificate_number11" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 0" label="负责人证件有效期起始日期" prop="certificate_validity_date_start1">
          <el-date-picker format="YYYYMMDD" value-format="YYYYMMDD" v-model="baForm.certificate_validity_date_start1"
            type="date" placeholder="请选择" style="width: 100%;" />
        </el-form-item>
        <el-form-item v-if="progress == 0" label="负责人证件有效期终止日期" prop="certificate_validity_date_end1">
          <el-date-picker format="YYYYMMDD" value-format="YYYYMMDD" v-model="baForm.certificate_validity_date_end1"
            type="date" placeholder="请选择" style="width: 100%;" />
        </el-form-item>
        <el-form-item v-show="progress == 0" label="负责人证件正面照片" prop="certificate_photo_front1">
          <el-upload v-model:file-list="fileList3" :http-request="upload3" list-type="picture-card"
            :on-preview="handlePicturePreview">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
          <el-dialog v-model="dialogVisible">
            <img w-full :src="dialogImageUrl" alt="Preview Image" />
          </el-dialog>
        </el-form-item>
        <el-form-item v-show="progress == 0" label="负责人证件背面照片" prop="certificate_photo_back1">
          <el-upload v-model:file-list="fileList6" :http-request="upload6" list-type="picture-card"
            :on-preview="handlePicturePreview">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
          <el-dialog v-model="dialogVisible">
            <img w-full :src="dialogImageUrl" alt="Preview Image" />
          </el-dialog>
        </el-form-item>
        <el-form-item v-if="progress == 0" label="法人代表姓名" prop="name12">
          <el-input v-model="baForm.name12" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 0" label="法人证件号码" prop="certificate_number12">
          <el-input v-model="baForm.certificate_number12" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 1" label="小程序实际经营内容、主要服务内容" prop="comment2" style="align-items: normal;">
          <el-input v-model="baForm.comment2" placeholder="请输入" type="textarea" :rows="3" />
        </el-form-item>
        <el-form-item v-if="progress == 1" label="服务内容类型" prop="service_content_types">
          <el-cascader v-model="baForm.service_content_types" ref="cascader2" :options="contentTypeArr" :props="props2"
            style="width:100%" @change="searchAreaChange2" />
        </el-form-item>
        <el-form-item v-if="progress == 1" prop="type2" label="前置审批类型">
          <el-select v-model.number="baForm.type2" placeholder="请选择">
            <el-option v-for="item in nrlxList" :key="item.type" :label="item.name" :value="item.type" />
          </el-select>
        </el-form-item>
        <el-form-item v-show="progress == 1 && baForm.type2 != 24" label="前置审批号">
          <el-input v-model="baForm.code2" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-show="progress == 1 && baForm.type2 != 24" label="前置审批媒体材料">
          <el-upload v-model:file-list="fileList7" :http-request="upload7" list-type="picture-card"
            :on-preview="handlePicturePreview">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
          <el-dialog v-model="dialogVisible">
            <img w-full :src="dialogImageUrl" alt="Preview Image" />
          </el-dialog>
        </el-form-item>
        <el-form-item v-if="progress == 1" label="负责人姓名" prop="name2">
          <el-input v-model="baForm.name2" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 1" label="负责人联系方式" prop="mobile2">
          <el-input v-model="baForm.mobile2" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 1" label="负责人电子邮件" prop="email2">
          <el-input v-model="baForm.email2" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 1" label="负责人应急联系方式" prop="emergency_contact2">
          <el-input v-model="baForm.emergency_contact2" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 1" label="负责人证件类型" prop="certificate_type2">
          <el-select v-model.number="baForm.certificate_type2" placeholder="请选择">
            <el-option v-for="item in certificate_types" :key="item.type" :label="item.name" :value="item.type" />
          </el-select>
        </el-form-item>
        <el-form-item v-if="progress == 1" label="负责人证件号码" prop="certificate_number2">
          <el-input v-model="baForm.certificate_number2" placeholder="请输入" />
        </el-form-item>
        <el-form-item v-if="progress == 1" label="负责人证件有效期起始日期" prop="certificate_validity_date_start2">
          <el-date-picker format="YYYYMMDD" value-format="YYYYMMDD" v-model="baForm.certificate_validity_date_start2"
            type="date" placeholder="请选择" style="width: 100%;" />
        </el-form-item>
        <el-form-item v-if="progress == 1" label="负责人证件有效期终止日期" prop="certificate_validity_date_end2">
          <el-date-picker format="YYYYMMDD" value-format="YYYYMMDD" v-model="baForm.certificate_validity_date_end2"
            type="date" placeholder="请选择" style="width: 100%;" />
        </el-form-item>
        <el-form-item v-show="progress == 1" label="负责人证件正面照片" prop="certificate_photo_front2">
          <el-upload v-model:file-list="fileList2" :http-request="upload2" list-type="picture-card"
            :on-preview="handlePicturePreview">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
          <el-dialog v-model="dialogVisible">
            <img w-full :src="dialogImageUrl" alt="Preview Image" />
          </el-dialog>
        </el-form-item>
        <el-form-item v-show="progress == 1" label="负责人证件背面照片" prop="certificate_photo_back2">
          <el-upload v-model:file-list="fileList1" :http-request="upload1" list-type="picture-card"
            :on-preview="handlePicturePreview">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
          <el-dialog v-model="dialogVisible">
            <img w-full :src="dialogImageUrl" alt="Preview Image" />
          </el-dialog>
        </el-form-item>

        <el-form-item v-show="progress == 2" label="互联网信息服务承诺书" prop="commitment_letter" style="align-items: normal;">
          <el-upload v-model:file-list="fileList8" :http-request="upload8">
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </el-form-item>
        <el-form-item v-show="progress == 2" label="主体更名函" prop="business_name_change_letter"
          style="align-items: normal;">
          <el-upload v-model:file-list="fileList9" :http-request="upload9">
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </el-form-item>
        <el-form-item v-show="progress == 2" label="党建确认函" prop="party_building_confirmation_letter"
          style="align-items: normal;">
          <el-upload v-model:file-list="fileList10" :http-request="upload10">
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </el-form-item>
        <el-form-item v-show="progress == 2" label="承诺视频" prop="promise_video" style="align-items: normal;">
          <el-upload v-model:file-list="fileList11" :http-request="upload11">
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </el-form-item>
        <el-form-item v-show="progress == 2" label="网站备案信息真实性责任告知书" prop="commitment_letter"
          style="align-items: normal;">
          <el-upload v-model:file-list="fileList12" :http-request="upload12">
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </el-form-item>
        <el-form-item v-show="progress == 2" label="小程序备案信息真实性承诺书" prop="business_name_change_letter"
          style="align-items: normal;">
          <el-upload v-model:file-list="fileList13" :http-request="upload13">
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </el-form-item>
        <el-form-item v-show="progress == 2" label="小程序建设方案书" prop="party_building_confirmation_letter"
          style="align-items: normal;">
          <el-upload v-model:file-list="fileList14" :http-request="upload14">
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </el-form-item>
        <el-form-item v-show="progress == 2" label="主体其它附件" prop="promise_video" style="align-items: normal;">
          <el-upload v-model:file-list="fileList15" multiple :http-request="upload15" :on-remove="handleRemove15">
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </el-form-item>
        <el-form-item v-show="progress == 2" label="小程序其它附件" prop="applets_other_materials"
          style="align-items: normal;">
          <el-upload v-model:file-list="fileList16" multiple :http-request="upload16" :on-remove="handleRemove16">
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </el-form-item>
        <el-form-item v-show="progress == 2" label="手持证件照" prop="holding_certificate_photo"
          style="align-items: normal;">
          <el-upload v-model:file-list="fileList17" :http-request="upload17">
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </el-form-item>
      </el-form>
    </el-drawer>
    <el-drawer v-model="lmVisible" :size="1000" :before-close="handleClose11" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">设置类目</span>
          <div>
            <el-button @click="handleClose11">取消</el-button>
            <el-button type="primary" @click="enterDialog11">确定</el-button>
          </div>
        </div>
      </template>
      <el-form v-if="lmVisible" ref="yyglForm" label-width="190" :model="commitForm" :rules="rules">
        <el-form-item label="类目" prop="categories">
          <el-cascader ref="cascader3" :options="allCategoryArr" :props="props4" style="width:600px"
            @change="allCateChange" />
        </el-form-item>
        <el-form-item v-if="qualifyName" label="资质文件" prop="certicates" style="align-items: normal;">
          <div v-if="qualifyName">{{ qualifyName }}</div>
          <div style="margin-bottom: 10px;">
            <span>上传原件或复印件，复印件务必加盖公司公章，文件格式为jpg、jpeg、bmp、gif或png，文件大小不超过10M，可拼图上传。</span>
            <a v-if="qualifyUrl" target="_blank" style="color: #576B95;" :href="qualifyUrl">查看示例</a>
          </div>
          <el-upload v-model:file-list="fileList22" multiple :http-request="upload22" list-type="picture-card"
            :on-remove="handleRemove22">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
        </el-form-item>
      </el-form>
    </el-drawer>
    <el-drawer v-model="descVisible" :size="1000" :before-close="handleClose12" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">设置小程序介绍</span>
          <div>
            <el-button @click="closeDialog12">取消</el-button>
            <el-button type="primary" @click="enterDialog12">确定</el-button>
          </div>
        </div>
      </template>
      <el-form v-if="descVisible" ref="yyglForm" label-width="190" :model="commitForm" :rules="rules">
        <el-form-item label="小程序介绍" prop="signature" style="align-items: normal;">
          <el-input v-model="commitForm.signature" type="textarea" :rows="3" placeholder="请输入" />
        </el-form-item>
      </el-form>
    </el-drawer>
    <el-drawer v-model="rzProgressVisible" :size="1200" :before-close="handleClose13" :show-close="false">
      <template #header>
        <div class="flex justify-between items-center">
          <span class="text-lg">认证进度</span>
          <div>
            <el-button @click="closeDialog13">取消</el-button>
          </div>
        </div>
      </template>
      <div class="row">
        <div class="label">任务流程状态:</div>
        <div class="value">{{ getRztaskStatus(rzInfo.task_status) }}</div>
      </div>
      <div class="row">
        <div class="label">管理员授权链接:</div>
        <div class="value">{{ rzInfo.auth_url }}</div>
      </div>
      <div class="row">
        <div class="label">任务流程状态:</div>
        <div class="value">{{ getRzApplyStatus(rzInfo.apply_status) }}</div>
      </div>
      <div class="row">
        <div class="label">认证订单号:</div>
        <div class="value">{{ rzInfo.orderid }}</div>
      </div>
      <div class="row" v-if="rzInfo.apply_status == 3">
        <div class="label">审核单被打回重填原因:</div>
        <div class="value">{{ rzInfo.refill_reason }}</div>
      </div>
      <div class="row" v-if="rzInfo.apply_status == 5">
        <div class="label">审核最终失败的原因:</div>
        <div class="value">{{ rzInfo.fail_reason }}</div>
      </div>
      <!-- <el-table :data="rzProgressData" class="table-style" ref="mbTable">
        <el-table-column align="left" label="管理员授权链接" width="500" prop="auth_url"></el-table-column>
        <el-table-column align="left" label="任务流程的状态" width="200" prop="task_status">
          <template #default="scope">
            {{ getRztaskStatus(scope.row.task_status) }}
          </template>
        </el-table-column>
        <el-table-column align="left" label="审核单状态" width="100" prop="apply_status">
          <template #default="scope">
            {{ getRzApplyStatus(scope.row.apply_status) }}
          </template>
        </el-table-column>
      </el-table> -->
    </el-drawer>
  </div>
</template>
<script setup>
import {
  miniList,
  fastRegister,
  templateList,
  miniCommit,
  allCategories,
  submitAudit,
  bindTester,
  miniQrcode,
  setHeadImage,
  setNickname,
  modifyDomain,
  miniRelease,
  auditStatus,
  mediaUpload,
  districtCode,
  certificateTypes,
  nrlxTypes,
  authAndIcp,
  raftList,
  addToTemplate,
  openBind,
  icpQuery,
  fileUpload,
  icpUpload,
  miniIcp,
  authQuery,
  miniEdit,
  miniDelete,
  addCategories,
  getCategories,
  setSignature,
  privacySetting,
  authLink,
  contentTypes,
  verifyTask,
  miniVersion
} from '@/api/diaochangguanli'
import { reactive, ref, onMounted, nextTick } from 'vue'
import { useAppStore } from "@/pinia";
import { useUserStore } from '@/pinia/modules/user'
import { ElMessage, ElMessageBox, useFormItem } from 'element-plus'
import { formatTimestamps } from '@/utils/format'
const rzVisible = ref(false)

const rzForm = ref({
  appId: '',
  email: '',
  mobile: '',
  name: '',
  desc1: '',
  id1: '',
  invoice_type: 1,
  bank_account: '',
  bank_name: '',
  desc2: '',
  enterprise_address: '',
  enterprise_phone: '',
  id2: '',
  customer_type: 1,
  taskid: '',
  qualification_other: [],
  account_name: '',
  account_name_type: 1,
  account_supplemental: [],
  pay_type: 1,
  auth_identification: '',
  auth_ident_material: [],
  third_party_phone: '',
  service_appid: '',
  qualification: '',
  auth_data: {
    customer_type: 1,
    taskid: '',
    qualification_other: [],
    account_name: '',
    account_name_type: 1,
    account_supplemental: [],
    pay_type: 1,
    auth_identification: '',
    auth_ident_material: [],
    third_party_phone: '',
    service_appid: '',
    qualification: '',
    contact_info: {
      email: '',
      mobile: '',
      name: ''
    },
    invoice_info: {
      electronic: {
        desc: '',
        id: ''
      },
      vat: {
        bank_account: '',
        bank_name: '',
        desc: '',
        enterprise_address: '',
        enterprise_phone: '',
        id: ''
      }
    },
  }
})

function enterDialog7() {
  if (rzForm.value.name) {
    rzForm.value.auth_data.contact_info.name = rzForm.value.name
    rzForm.value.auth_data.contact_info.email = rzForm.value.email
    rzForm.value.auth_data.contact_info.mobile = rzForm.value.mobile
    rzForm.value.auth_data.invoice_info.invoice_type = rzForm.value.invoice_type
    rzForm.value.auth_data.invoice_info.electronic.id = rzForm.value.id1
    rzForm.value.auth_data.invoice_info.electronic.desc = rzForm.value.desc1
    rzForm.value.auth_data.invoice_info.vat.enterprise_phone = rzForm.value.enterprise_phone
    rzForm.value.auth_data.invoice_info.vat.id = rzForm.value.id2
    rzForm.value.auth_data.invoice_info.vat.enterprise_address = rzForm.value.enterprise_address
    rzForm.value.auth_data.invoice_info.vat.bank_name = rzForm.value.bank_name
    rzForm.value.auth_data.invoice_info.vat.bank_account = rzForm.value.bank_account
    rzForm.value.auth_data.invoice_info.vat.desc = rzForm.value.desc2
    rzForm.value.auth_data.customer_type = rzForm.value.customer_type
    rzForm.value.auth_data.pay_type = rzForm.value.pay_type
    rzForm.value.auth_data.account_name = rzForm.value.account_name
    rzForm.value.auth_data.account_name_type = rzForm.value.account_name_type
    rzForm.value.auth_data.service_appid = rzForm.value.service_appid
    rzForm.value.auth_data.third_party_phone = rzForm.value.third_party_phone
  }
  let rzParams = JSON.parse(JSON.stringify(rzForm.value))
  for (const key in rzParams) {
    if (!['appId', 'auth_data'].includes(key)) {
      delete rzParams[key]
    }
  }
  console.log(rzParams, 'rzForm.value')
  yyglForm.value.validate((valid) => {
    if (valid) {
      authAndIcp(rzParams).then(res => {
        if (res.code == 200) {
          if (res.result.errcode != 0) {
            ElMessage({
              type: 'error',
              message: errMap[res.result.errcode] || res.result.errmsg
            })
            return
          } else {
            ElMessage({
              type: 'success',
              message: '认证成功'
            })
            initRzForm()
            rzVisible.value = false
          }
        }
      })
    }
  })
}
function initRzForm() {
  rzForm.value = {
    appId: '',
    email: '',
    mobile: '',
    name: '',
    desc1: '',
    id1: '',
    invoice_type: 1,
    bank_account: '',
    bank_name: '',
    desc2: '',
    enterprise_address: '',
    enterprise_phone: '',
    id2: '',
    customer_type: 1,
    taskid: '',
    qualification_other: [],
    account_name: '',
    account_name_type: 1,
    account_supplemental: [],
    pay_type: 1,
    auth_identification: '',
    auth_ident_material: [],
    third_party_phone: '',
    service_appid: '',
    qualification: '',
    auth_data: {
      customer_type: 1,
      taskid: '',
      qualification_other: [],
      account_name: '',
      account_name_type: 1,
      account_supplemental: [],
      pay_type: 1,
      auth_identification: '',
      auth_ident_material: [],
      third_party_phone: '',
      service_appid: '',
      qualification: '',
      contact_info: {
        email: '',
        mobile: '',
        name: ''
      },
      invoice_info: {
        electronic: {
          desc: '',
          id: ''
        },
        vat: {
          bank_account: '',
          bank_name: '',
          desc: '',
          enterprise_address: '',
          enterprise_phone: '',
          id: ''
        }
      },
    }
  }
  fileList18.value = []
  fileList19.value = []
  fileList20.value = []
}

const baForm = ref({
  areas: [],
  progress: 0,
  appId: '',
  certificate_number: '',
  certificate_photo_back: '',
  certificate_photo_front: '',
  certificate_type: '',
  certificate_validity_date_end: '',
  certificate_validity_date_start: '',
  emergency_contact: '',
  address1: '',
  city1: '',
  comment1: '',
  district1: '',
  name1: '',
  province1: '',
  record_number1: '',
  type1: 1,
  certificate_type1: '',
  certificate_address1: '',
  certificate_number1: '',
  certificate_photo1: '',
  name11: '',
  mobile1: '',
  email1: '',
  emergency_contact1: '',
  certificate_type11: '',
  certificate_number11: '',
  certificate_validity_date_start1: '',
  certificate_validity_date_end1: '',
  certificate_photo_front1: '',
  certificate_photo_back1: '',
  name12: '',
  certificate_number12: '',
  service_content_types: [],
  comment2: '',
  code2: '',
  media2: '',
  type2: '',
  name2: '',
  email2: '',
  mobile2: '',
  emergency_contact2: '',
  certificate_type2: '',
  certificate_number2: '',
  certificate_validity_date_end2: '',
  certificate_validity_date_start2: '',
  certificate_photo_back2: '',
  certificate_photo_front2: '',
  icp_applets: {
    base_info: {
      appid: '',
      comment: '',
      service_content_types: [],
      nrlx_details: [{
        code: '',
        media: '',
        type: ''
      }]
    },
    principal_info: {
      authorization_letter: '',
      certificate_number: '',
      certificate_photo_back: '',
      certificate_photo_front: '',
      certificate_type: '',
      certificate_validity_date_end: '',
      certificate_validity_date_start: '',
      email: '',
      emergency_contact: '',
      mobile: '',
      name: '',
      verify_task_id: ''
    }
  },
  icp_materials: {
    applets_other_materials: [],
    authenticity_commitment_letter: [],
    authenticity_responsibility_letter: [],
    business_name_change_letter: [],
    commitment_letter: [],
    holding_certificate_photo: [],
    party_building_confirmation_letter: [],
    promise_video: [],
    subject_other_materials: [],
    website_construction_proposal: []
  },
  icp_subject: {
    base_info: {
      address: '',
      city: '',
      comment: '',
      district: '',
      name: '',
      province: '',
      record_number: '',
      type: ''
    },
    legal_person_info: {
      certificate_number: '',
      name: ''
    },
    organize_info: {
      certificate_address: '',
      certificate_number: '',
      certificate_photo: '',
      certificate_type: ''//integer
    },
    personal_info: {
      residence_permit: ''
    },
    principal_info: {
      authorization_letter: '',
      certificate_number: '',
      certificate_photo_back: '',
      certificate_photo_front: '',
      certificate_type: '',
      certificate_validity_date_end: '',
      certificate_validity_date_start: '',
      email: '',
      emergency_contact: '',
      mobile: '',
      name: '',
      verify_task_id: ''
    }
  }
})
function initBaForm() {
  baForm.value = {
    areas: [],
    progress: 0,
    appId: '',
    certificate_number: '',
    certificate_photo_back: '',
    certificate_photo_front: '',
    certificate_type: '',
    certificate_validity_date_end: '',
    certificate_validity_date_start: '',
    emergency_contact: '',
    address1: '',
    city1: '',
    comment1: '',
    district1: '',
    name1: '',
    province1: '',
    record_number1: '',
    type1: 1,
    certificate_type1: '',
    certificate_address1: '',
    certificate_number1: '',
    certificate_photo1: '',
    name11: '',
    mobile1: '',
    email1: '',
    emergency_contact1: '',
    certificate_type11: '',
    certificate_number11: '',
    certificate_validity_date_start1: '',
    certificate_validity_date_end1: '',
    certificate_photo_front1: '',
    certificate_photo_back1: '',
    name12: '',
    certificate_number12: '',
    service_content_types: [],
    comment2: '',
    code2: '',
    media2: '',
    type2: '',
    name2: '',
    email2: '',
    mobile2: '',
    emergency_contact2: '',
    certificate_type2: '',
    certificate_number2: '',
    certificate_validity_date_end2: '',
    certificate_validity_date_start2: '',
    certificate_photo_back2: '',
    certificate_photo_front2: '',
    icp_applets: {
      base_info: {
        appid: '',
        comment: '',
        service_content_types: [],
        nrlx_details: [{
          code: '',
          media: '',
          type: ''
        }]
      },
      principal_info: {
        authorization_letter: '',
        certificate_number: '',
        certificate_photo_back: '',
        certificate_photo_front: '',
        certificate_type: '',
        certificate_validity_date_end: '',
        certificate_validity_date_start: '',
        email: '',
        emergency_contact: '',
        mobile: '',
        name: '',
        verify_task_id: ''
      }
    },
    icp_materials: {
      applets_other_materials: [],
      authenticity_commitment_letter: [],
      authenticity_responsibility_letter: [],
      business_name_change_letter: [],
      commitment_letter: [],
      holding_certificate_photo: [],
      party_building_confirmation_letter: [],
      promise_video: [],
      subject_other_materials: [],
      website_construction_proposal: []
    },
    icp_subject: {
      base_info: {
        address: '',
        city: '',
        comment: '',
        district: '',
        name: '',
        province: '',
        record_number: '',
        type: ''
      },
      legal_person_info: {
        certificate_number: '',
        name: ''
      },
      organize_info: {
        certificate_address: '',
        certificate_number: '',
        certificate_photo: '',
        certificate_type: ''//integer
      },
      personal_info: {
        residence_permit: ''
      },
      principal_info: {
        authorization_letter: '',
        certificate_number: '',
        certificate_photo_back: '',
        certificate_photo_front: '',
        certificate_type: '',
        certificate_validity_date_end: '',
        certificate_validity_date_start: '',
        email: '',
        emergency_contact: '',
        mobile: '',
        name: '',
        verify_task_id: ''
      }
    }
  }
  progress.value = 0
  fileList1.value = []
  fileList2.value = []
  fileList3.value = []
  fileList4.value = []
  fileList5.value = []
  fileList6.value = []
  fileList7.value = []
  fileList8.value = []
  fileList9.value = []
  fileList10.value = []
  fileList11.value = []
  fileList12.value = []
  fileList13.value = []
  fileList14.value = []
  fileList15.value = []
  fileList16.value = []
  fileList17.value = []
}
function enterDialog9() {
  if (baForm.value.name1) {
    baForm.value.icp_subject.base_info.type = baForm.value.type1
    baForm.value.icp_subject.base_info.name = baForm.value.name1
    baForm.value.icp_subject.base_info.address = baForm.value.address1
    baForm.value.icp_subject.base_info.comment = baForm.value.comment1
    baForm.value.icp_subject.base_info.record_number = baForm.value.record_number1
    baForm.value.icp_subject.organize_info.certificate_type = baForm.value.certificate_type1
    baForm.value.icp_subject.organize_info.certificate_number = baForm.value.certificate_number1
    baForm.value.icp_subject.organize_info.certificate_address = baForm.value.certificate_address1
    baForm.value.icp_subject.principal_info.name = baForm.value.name11
    baForm.value.icp_subject.principal_info.mobile = baForm.value.mobile1
    baForm.value.icp_subject.principal_info.email = baForm.value.email1
    baForm.value.icp_subject.principal_info.emergency_contact = baForm.value.emergency_contact1
    baForm.value.icp_subject.principal_info.certificate_type = baForm.value.certificate_type11
    baForm.value.icp_subject.principal_info.certificate_number = baForm.value.certificate_number11
    baForm.value.icp_subject.principal_info.certificate_validity_date_start = baForm.value.certificate_validity_date_start1
    baForm.value.icp_subject.principal_info.certificate_validity_date_end = baForm.value.certificate_validity_date_end1
    baForm.value.icp_subject.legal_person_info.name = baForm.value.name12
    baForm.value.icp_subject.legal_person_info.certificate_number = baForm.value.certificate_number12
    baForm.value.icp_applets.base_info.nrlx_details[0].type = baForm.value.type2
    baForm.value.icp_applets.base_info.nrlx_details[0].code = baForm.value.code2
    baForm.value.icp_applets.base_info.comment = baForm.value.comment2
    baForm.value.icp_applets.principal_info.name = baForm.value.name2
    baForm.value.icp_applets.principal_info.mobile = baForm.value.mobile2
    baForm.value.icp_applets.principal_info.email = baForm.value.email2
    baForm.value.icp_applets.principal_info.emergency_contact = baForm.value.emergency_contact2
    baForm.value.icp_applets.principal_info.certificate_type = baForm.value.certificate_type2
    baForm.value.icp_applets.principal_info.certificate_number = baForm.value.certificate_number2
    baForm.value.icp_applets.principal_info.certificate_validity_date_start = baForm.value.certificate_validity_date_start2
    baForm.value.icp_applets.principal_info.certificate_validity_date_end = baForm.value.certificate_validity_date_end2
  }
  let baParams = JSON.parse(JSON.stringify(baForm.value))
  for (const key in baParams) {
    if (!['appId', 'icp_applets', 'icp_materials', 'icp_subject'].includes(key)) {
      delete baParams[key]
    }
  }
  console.log(baParams, 'baParams.value')
  yyglForm.value.validate((valid) => {
    if (valid) {
      miniIcp(baParams).then(res => {
        if (res.code == 200) {
          if (res.result.errcode != 0) {
            ElMessage({
              type: 'error',
              message: errMap[res.result.errcode] || res.result.errmsg
            })
            return
          } else {
            ElMessage({
              type: 'success',
              message: '备案成功'
            })
            initBaForm()
            baVisible.value = false
          }
        }
      })
    }
  })
}
const props1 = {
  checkStrictly: false,
  label: 'name',
  value: 'code',
  children: 'sub_list'
}
function uploadSuccess(res, field) {
  if (res.code != 200) {
    ElMessage({
      type: 'error',
      message: res.message
    })
    rzForm.value[field].pop()
    return
  }
}
function handleClose7() {
  initRzForm()
  rzVisible.value = false
}
function closeDialog7() {
  initRzForm()
  rzVisible.value = false
}
// 通过该函数，可以获取组件当前所在的表单项formItem
const { formItem } = useFormItem()
const errMap = {
  85001: '微信号不存在或微信号设置为不可搜索',
  85002: '小程序绑定的体验者数量达到上限',
  85003: '微信号绑定的小程序体验者达到上限',
  85004: '微信号已经绑定',
  91001: '通过api注册的小程序才可调用该接口改名',
  91003: '改名状态不合法',
  91004: '昵称不合法',
  91005: '昵称 15 天主体保护',
  91007: '昵称已被占用',
  91008: '昵称命中 7 天侵权保护期',
  91009: '需要提交材料',
  91010: '其他错误',
  91011: '查不到昵称修改审核单信息',
  91012: '其他错误',
  91013: '占用名字过多',
  91014: '+号规则 同一类型关联名主体不一致',
  91015: '原始名不同类型主体不一致',
  91016: '名称占用者 ≥2',
  91017: '+号规则 不同类型关联名主体不一致',
  40007: '不合法的媒体文件 id',
  91019: '小程序正在审核中',
  91028: '试用小程序不支持使用该接口更改名称',
  91029: '可通过认证改名',
  '-1': '系统繁忙，此时请开发者稍候再试',
  40001: '获取 access_token 时 AppSecret 错误，或者 access_token 无效。请开发者认真比对 AppSecret 的正确性，或查看是否正在为恰当的公众号调用接口',
  40007: '不合法的媒体文件 id',
  40097: '参数错误',
  41006: '缺少 media_id 参数',
  46001: '不存在媒体数据，media_id 不存在',
  47001: '解析 JSON/XML 内容错误;post 数据中参数缺失;检查修正后重试。',
  40009: '图片尺寸太大',
  53202: '本月头像修改次数已用完',
  40014: '获取 access_token 时 AppSecret 错误，或者 access_token 无效。请开发者认真比对 AppSecret 的正确性，或查看是否正在为恰当的公众号调用接口',
  85015: '该账号不是小程序账号',
  85017: '域名输入为空，或者没有新增域名，请确认小程序已经添加了域名或该域名是否没有在第三方平台添加',
  85018: '域名没有在第三方平台设置',
  85301: '存在 “不符合域名规则的域名”导致无修改。',
  85302: '存在 “ 缺少ICP备案的域名”导致无修改',
  85303: '同时存在“不符合域名规则的域名”以及“ 缺少ICP备案的域名”导致无修改。',
  86000: '不是由第三方代小程序进行调用',
  86001: '不存在第三方的已经提交的代码',
  85006: '标签格式错误',
  85007: '页面路径错误',
  85008: '当前小程序没有已经审核通过的类目，请添加类目成功后重试',
  85009: '已经有正在审核的版本',
  85010: 'item_list 有项目为空',
  85011: '标题填写错误',
  85023: '审核列表填写的项目数不在 1-5 以内',
  85077: '小程序类目信息失效（类目中含有官方下架的类目，请重新选择类目）',
  86002: '小程序还未设置昵称、头像、简介。请先设置完后再重新提交',
  85085: '小程序提审数量已达本月上限，请点击查看《自助临时申请额度》',
  85086: '提交代码审核之前需提前上传代码',
  85087: '小程序已使用 api navigateToMiniProgram，请声明跳转 appid 列表后再次提交',
  87006: '小游戏不能提交',
  86007: '小程序禁止提交',
  85051: 'version_desc或者preview_info超限',
  85092: 'preview_info格式错误',
  85093: 'preview_info 视频或者图片个数超限',
  85094: '需提供审核机制说明信息',
  86009: '服务商新增小程序代码提审能力被限制',
  86010: '服务商迭代小程序代码提审能力被限制',
  9400001: '该开发小程序已开通小程序直播权限，不支持发布版本。如需发版，请解绑开发小程序后再操作。',
  9402202: '请勿频繁提交，待上一次操作完成后再提交',
  61040: '"ext.json配置的隐私接口xxx无权限，请申请权限后再提交审核。或者代码中含有ext.json未配置隐私接口xxx(暂无权限)，请配置并申请权限或者承诺不使用这些接口（设置参数privacy_api_not_use为true）后再提交审核。',
  86000: '不是由第三方代小程序进行调用',
  86001: '不存在第三方的已经提交的代码',
  85012: '无效的审核 id',
  80082: '没有权限使用该插件',
  9402203: '标准模板extjson错误',
  85013: '无效的自定义配置',
  9402202: '请勿频繁提交，待上一次操作完成后再提交',
  85014: '无效的模板编号',
  85043: '模板错误',
  85044: '代码包超过大小限制',
  85045: 'ext_json 有不存在的路径',
  85046: 'tabBar 中缺少 path',
  85047: 'pages 字段为空',
  85048: 'ext_json 解析失败',
  80067: '找不到使用的插件',
  80066: '非法的插件版本',
  85310: 'requiredPrivateInfos 的格式有问题或者api名称写错了',
  85312: 'requiredPrivateInfos 配置了没有权限的api',
  85311: 'requiredPrivateInfos包含了互斥的api',
  85019: '没有审核版本',
  85020: '审核状态未满足发布',
  41001: '',
  89249: '该appid已有转正任务执行中，距上次任务 24h 后再试',
  86004: '无效微信号',
  89247: '系统内部错误',
  61070: '法人姓名与微信号不一致',
  89248: '企业代码类型无效，请选择正确类型填写',
  89250: '未找到该任务',
  89251: '模板消息已下发，待法人人脸核身校验',
  89252: '法人&企业信息一致性校验中',
  89253: '缺少参数',
  89254: '第三方权限集不全，请补充权限集后重试',
  89255: 'code参数无效，请检查code长度以及内容是否正确；注意code_type的值不同需要传的code长度不一样'
}
defineOptions({
  name: 'Yygl'
})
const appStore = useAppStore()
const form = ref({
  code: '',
  codeType: 1,
  componentPhone: '',
  legalPersonaName: '',
  legalPersonaWechat: '',
  license: '',
  name: ''
})

const searchInfo = ref({
  nickName: ''
})

const userStore = useUserStore()
const headerOdj = ref({ token: userStore.token })
const adminUrl = ref('')
adminUrl.value = import.meta.env.VITE_BASE_PATH + '/file/upload'
const page = ref(1)
const total = ref(0)
const pageSize = ref(10)
const dialogFormVisible = ref(false)
let validateImage = (rule, value, callback) => {
  if (!form.value.license) {
    callback(new Error('请上传图片'))
  } else {
    callback()
  }
}
let validateImage1 = (rule, value, callback) => {
  if (!commitForm.value.headImage) {
    callback(new Error('请上传图片'))
  } else {
    callback()
  }
}
let validate22 = (rule, value, callback) => {
  if (fileList22.value.length == 0) {
    callback(new Error('请上传文件'))
  } else {
    callback()
  }
}
const rules = reactive({
  code: [{ required: true, message: '请输入企业代码', trigger: 'blur' }],
  codeType: [{ required: true, message: '请选择企业代码类型', trigger: 'change' }],
  legalPersonaName: [{ required: true, message: '请输入法人姓名', trigger: 'blur' }],
  legalPersonaWechat: [{ required: true, message: '请输入法人微信号', trigger: 'blur' }],
  name: [{ required: true, message: '请输入企业名', trigger: 'blur' }],
  license: [{ required: true, validator: validateImage, trigger: 'change' }],
  wechatid: [{ required: true, message: '请输入微信号', trigger: 'blur' }],
  headImage: [{ required: true, validator: validateImage1, trigger: 'change' }],
  nickName: [{ required: true, message: '请输入小程序名称', trigger: 'blur' }],
  action: [{ required: true, message: '请选择操作类型', trigger: 'change' }],
  downloadDomain: [{ required: true, message: '请输入downloadFile合法域名', trigger: 'blur' }],
  requestDomain: [{ required: true, message: '请输入request合法域名', trigger: 'blur' }],
  tcpDomain: [{ required: true, message: '请输入tcp合法域名', trigger: 'blur' }],
  udpDomain: [{ required: true, message: '请输入udp合法域名', trigger: 'blur' }],
  uploadDomain: [{ required: true, message: '请输入pload合法域名', trigger: 'blur' }],
  wsRequestDomain: [{ required: true, message: '请输入wsRequest合法域名', trigger: 'blur' }],
  categories: [{ required: true, message: '请选择类目', trigger: 'change' }],
  signature: [{ required: true, message: '请输入小程序介绍', trigger: 'blur' }],
  certicates: [{ required: true, validator: validate22, trigger: 'change' }],
})
let validate1 = (rule, value, callback) => {
  if (fileList3.value.length == 0) {
    callback(new Error('请上传文件'))
  } else {
    callback()
  }
}
let validate2 = (rule, value, callback) => {
  if (fileList3.value.length == 0) {
    callback(new Error('请上传文件'))
  } else {
    callback()
  }
}
let validate3 = (rule, value, callback) => {
  if (fileList7.value.length == 0) {
    callback(new Error('请上传文件'))
  } else {
    callback()
  }
}
let validate4 = (rule, value, callback) => {
  if (fileList2.value.length == 0) {
    callback(new Error('请上传文件'))
  } else {
    callback()
  }
}
let validate5 = (rule, value, callback) => {
  if (fileList1.value.length == 0) {
    callback(new Error('请上传文件'))
  } else {
    callback()
  }
}
let validate21 = (rule, value, callback) => {
  if (fileList21.value.length == 0) {
    callback(new Error('请上传文件'))
  } else {
    callback()
  }
}
const rzRules = reactive({
  name: [{ required: true, message: '请输入认证联系人姓名', trigger: 'blur' }],
  email: [{ required: true, message: '请输入认证联系人邮箱', trigger: 'blur' }],
  mobile: [{ required: true, message: '请输入认证联系人手机号', trigger: 'blur' }],
  account_name: [{ required: true, message: '请输入账号名称', trigger: 'blur' }],
  invoice_type: [{ required: true, message: '请选择发票类型', trigger: 'change' }],
  id1: [{ required: true, message: '请输入纳税识别号', trigger: 'blur' }],
  id2: [{ required: true, message: '请输入纳税识别号', trigger: 'blur' }],
  enterprise_phone: [{ required: true, message: '请输入企业电话', trigger: 'blur' }],
  enterprise_address: [{ required: true, message: '请输入企业注册地址', trigger: 'blur' }],
  customer_type: [{ required: true, message: '请选择认证主体类型', trigger: 'change' }],
  pay_type: [{ required: true, message: '请选择支付方式', trigger: 'change' }],
  account_name_type: [{ required: true, message: '请选择小程序账号名称命名类型', trigger: 'change' }],
  third_party_phone: [{ required: true, message: '请输入第三方联系电话', trigger: 'blur' }],
  service_appid: [{ required: true, message: '请输入服务市场appid', trigger: 'blur' }],
})
const baRules = reactive({
  type1: [{ required: true, message: '请选择主体性质', trigger: 'change' }],
  name1: [{ required: true, message: '请输入主办单位名称', trigger: 'blur' }],
  areas: [{ required: true, message: '请选择备案区域', trigger: 'change' }],
  address1: [{ required: true, message: '请输入通讯地址', trigger: 'blur' }],
  certificate_type1: [{ required: true, message: '请选择主体证件类型', trigger: 'change' }],
  certificate_number1: [{ required: true, message: '请输入主体证件号码', trigger: 'blur' }],
  certificate_address1: [{ required: true, message: '请输入主体证件住所', trigger: 'blur' }],
  name11: [{ required: true, message: '请输入负责人姓名', trigger: 'blur' }],
  mobile1: [{ required: true, message: '请输入负责人联系方式', trigger: 'blur' }],
  email1: [{ required: true, message: '请输入负责人电子邮件', trigger: 'blur' }],
  emergency_contact1: [{ required: true, message: '请输入负责人应急联系方式', trigger: 'blur' }],
  certificate_type11: [{ required: true, message: '请选择负责人证件类型', trigger: 'change' }],
  certificate_number11: [{ required: true, message: '请输入负责人证件号码', trigger: 'blur' }],
  certificate_validity_date_start1: [{ required: true, message: '请选择负责人证件有效期起始日期', trigger: 'change' }],
  certificate_validity_date_end1: [{ required: true, message: '请选择负责人证件有效期终止日期', trigger: 'change' }],
  certificate_photo_front1: [{ required: true, validator: validate1, trigger: 'change' }],
  certificate_photo_back1: [{ required: true, validator: validate2, trigger: 'change' }],
  name12: [{ required: true, message: '请输入法人代表姓名', trigger: 'blur' }],
  certificate_number12: [{ required: true, message: '请输入法人证件号码', trigger: 'blur' }],
  service_content_types: [{ required: true, message: '请选择小程序服务内容类型', trigger: 'change' }],
  comment2: [{ required: true, message: '请输入小程序实际经营内容、主要服务内容', trigger: 'blur' }],
  type2: [{ required: true, message: '请选择前置审批项', trigger: 'change' }],
  code2: [{ required: true, message: '请输入前置审批号', trigger: 'blur' }],
  media2: [{ required: true, validator: validate3, trigger: 'change' }],
  name2: [{ required: true, message: '请输入负责人姓名', trigger: 'blur' }],
  mobile2: [{ required: true, message: '请输入负责人联系方式', trigger: 'blur' }],
  email2: [{ required: true, message: '请输入负责人电子邮件', trigger: 'blur' }],
  emergency_contact2: [{ required: true, message: '请输入负责人应急联系方式', trigger: 'blur' }],
  certificate_type2: [{ required: true, message: '请输入负责人证件类型', trigger: 'blur' }],
  certificate_number2: [{ required: true, message: '请输入负责人证件号码', trigger: 'blur' }],
  certificate_validity_date_start2: [{ required: true, message: '请选择负责人证件有效期起始日期', trigger: 'change' }],
  certificate_validity_date_end2: [{ required: true, message: '请选择负责人证件有效期起始日期', trigger: 'change' }],
  certificate_photo_front2: [{ required: true, validator: validate4, trigger: 'change' }],
  certificate_photo_back2: [{ required: true, validator: validate5, trigger: 'change' }],
  certificate_photo1: [{ required: true, validator: validate21, trigger: 'change' }],
})
const fileList5 = ref([])
function upload5(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      form.value.license = res.result
      yyglForm.value.validateField('license')
    } else {
      fileList5.value.pop()
    }
  })
}
// const uploadSuccess5 = (res) => {
//   if (res.code != 200) {
//     ElMessage({
//       type: 'warning',
//       message: res.message
//     })
//     fileList5.value.pop()
//     return
//   }
//   form.value.license = res.result
//   yyglForm.value.validateField('license')
// }
let dialogVisible = ref(false)
let dialogImageUrl = ref()

//图片预览
const handlePicturePreview = (file, files) => {
  dialogImageUrl.value = file.url;
  dialogVisible.value = true
}

const yyglForm = ref(null)

const initForm = () => {
  yyglForm.value.resetFields()
  form.value = {
    code: '',
    codeType: 1,
    componentPhone: '',
    legalPersonaName: '',
    legalPersonaWechat: '',
    license: '',
    name: ''
  }
  fileList5.value = []
}

const initCommitForm = () => {
  yyglForm.value?.resetFields()
  commitForm.value = {
    categories: [],
    templateId: '',
    userDesc: '',
    userVersion: '',
    progress: 0,
    appId: commitForm.value.appId,
    itemList: [],
    miniStatus: 0,
    wechatid: '',
    headImage: '',
    nickName: '',
    action: 'add',
    downloadDomain: '',
    requestDomain: '',
    tcpDomain: '',
    udpDomain: '',
    uploadDomain: '',
    wsRequestDomain: '',
    auditId: '',
    signature: ''
  }
  link.value = ''
}
const isEdit = ref(false)
const closeDialog = () => {
  initForm()
  dialogFormVisible.value = false
}
const handleClose = (done) => {
  initForm()
  done()
}
const handleClose1 = (done) => {
  commitDialog.value = false
}

const handleCurrentChange = (val) => {
  page.value = val
  getTableData()
}
const tableData = ref([])
// 查询
const getTableData = async () => {
  const res = await miniList({
    pageNumber: page.value,
    pageSize: pageSize.value,
    ...searchInfo.value
  })
  if (res.code == 200) {
    tableData.value = res.result.data
    total.value = res.result.total
  }
}
getTableData()

const commitData = ref([])

onMounted(() => {

})
const types = ['', '统一社会信用代码（18 位）', '组织机构代码（9 位 xxxxxxxx-x）', '营业执照注册号(15 位)']
function getType(val) {
  return types[val]
}
const ststsusList = ['未发布', '审核中', '审核不通过', '审核延迟', '审核通过待发布', '已发布']
function getStatus(val) {
  return ststsusList[val]
}
const enterDialog = async () => {
  yyglForm.value.validate(async (valid) => {
    if (valid) {
      console.log(form.value, 'form.value');
      let res
      if (isEdit.value) {
        res = await miniEdit(form.value)
      } else {
        res = await fastRegister(form.value)
      }
      if (res.code == 200) {
        ElMessage({
          type: 'success',
          message: isEdit.value ? '编辑成功' : '添加成功!'
        })
        getTableData()
        initForm()
        dialogFormVisible.value = false
        // if (res.errcode != 0) {

        //   return
        // } else {

        // }
      } else {
        //   ElMessage({
        //     type: 'error',
        //     message: errMap[res.errcode] || res.result.errmsg
        //   })
      }
    }
  })
}
const enterDialog1 = async () => {
  console.log(commitForm.value);
  if (commitForm.value.progress == 0) {
    if (commitForm.value.templateId === '') {
      ElMessage({
        type: 'info',
        message: '请选择模版'
      })
      return
    }
    miniCommit(commitForm.value).then(res => {
      if (res.code == 200) {
        if (res.result.errcode != 0) {
          ElMessage({
            type: 'error',
            message: errMap[res.result.errcode] || res.result.errmsg
          })
          return
        } else {
          ElMessage({
            type: 'success',
            message: '生成成功'
          })
          initCommitForm()
          commitDialog.value = false
        }
      }
    })
  }
  if (commitForm.value.progress == 1) {
    submitAudit(commitForm.value).then(res => {
      if (res.code == 200) {
        if (res.result.errcode != 0) {
          ElMessage({
            type: 'error',
            message: errMap[res.result.errcode] || res.result.errmsg
          })
          return
        } else {
          ElMessage({
            type: 'success',
            message: '提交审核成功'
          })
          initCommitForm()
          commitDialog.value = false
        }
      }
    })
  }
}
const title = ref('新增')
const register = async () => {
  isEdit.value = false
  dialogFormVisible.value = true
}
const edit = async (row) => {
  console.log(row, 'row')
  isEdit.value = true
  title.value = '编辑'
  form.value = JSON.parse(JSON.stringify(row))
  if (form.value.license) {
    fileList5.value = [{
      name: '1',
      url: form.value.license
    }]
  }
  dialogFormVisible.value = true
}
const del = async (row) => {
  ElMessageBox.confirm(
    '确认删除?',
    '提示',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }
  ).then(async () => {
    const res = await miniDelete(row.id)
    if (res.code === 200) {
      ElMessage({
        type: 'success',
        message: '删除成功!'
      })
      getTableData()
    }
  }).catch(() => {
    ElMessage({
      type: 'info',
      message: '已取消删除'
    })
  })
}
const commitForm = ref({
  categories: [],
  templateId: '',
  userDesc: '',
  userVersion: '',
  progress: 0,
  appId: '',
  itemList: [],
  miniStatus: 0,
  wechatid: '',
  headImage: '',
  nickName: '',
  action: 'add',
  downloadDomain: '',
  requestDomain: '',
  tcpDomain: '',
  udpDomain: '',
  uploadDomain: '',
  wsRequestDomain: '',
  auditId: '',
  signature: ''
})
const commitDialog = ref(false)
const versionInfo = ref({})
function commit(row) {
  templateList().then(res => {
    commitForm.value.miniStatus = row.miniStatus
    commitForm.value.appId = row.appId
    commitForm.value.auditId = row.programAuditId
    commitData.value = res.result.template_list
    commitDialog.value = true
  })
  miniVersion(row.appId).then(res => {
    versionInfo.value = res.result
  })
}

const multipleTable = ref(null)
function selectInfo(selection, row) {
  console.log(selection, row);
  multipleTable.value.clearSelection();
  if (selection.length == 0) return;
  multipleTable.value.toggleRowSelection(row, true);
  commitForm.value.templateId = row.template_id
  commitForm.value.userDesc = row.user_desc
  commitForm.value.userVersion = row.user_version

}
const onSubmit = () => {
  page.value = 1
  getTableData()
}

const onReset = () => {
  page.value = 1
  searchInfo.value = {
    nickName: ''
  }
  getTableData()
}
function changeProgress(val) {
  if (val == 1) {
    getCategories({ appId: commitForm.value.appId }).then(res => {
      //categoryArr.value = res.result
      //res.result.
      console.log(res.result.categories, 'res.result.categories')
      let arr = res.result.categories.map(item => item.first)
      let result = Array.from(new Set(arr))
      console.log(result, 'result');
      categoryArr.value = []
      result.forEach((m, i) => {
        categoryArr.value.push({
          id: m,
          children: []
        })
        res.result.categories.forEach(item => {
          if (m == item.first) {
            categoryArr.value[i].name = item.first_name
            categoryArr.value[i].children.push({
              name: item.second_name,
              id: item.second
            })
          }
        })
      })
      console.log(categoryArr.value, 'categoryArr.value');
    })
  }
  commitForm.value.progress = val
}
const props = {
  multiple: true,
  label: 'name',
  value: 'id'
}
const props4 = {
  label: 'name',
  value: 'id'
}
const props2 = {
  multiple: true,
  label: 'name',
  value: 'type'
}
const categoryArr = ref([])
const cascader = ref(null)
const searchAreaChange = (val, selectedData) => {
  console.log(val, selectedData, 'val')
  let checkedNodes = cascader.value.getCheckedNodes().filter(item => item.pathValues.length > 1)
  console.log(checkedNodes, 'checkedNodes')
  commitForm.value.itemList = checkedNodes.map(item => {
    return {
      firstClass: item.pathLabels[0],
      firstId: item.pathValues[0],
      secondClass: item.pathLabels[1],
      secondId: item.pathValues[1]
    }
  })
}
const weixinVisible = ref(false)
function handleClose2() {
  initCommitForm()
  weixinVisible.value = false
}
function bindPerson() {
  weixinVisible.value = true
}
function enterDialog2() {
  yyglForm.value.validate(async (valid) => {
    if (valid) {
      let res = await bindTester(commitForm.value)
      if (res.code == 200) {
        if (res.result.errcode != 0) {
          ElMessage({
            type: 'error',
            message: errMap[res.result.errcode] || res.result.errmsg
          })
          return
        } else {
          ElMessage({
            type: 'success',
            message: '绑定成功'
          })
          initCommitForm()
          weixinVisible.value = false
        }
      }
    }
  })
}
const qrcodeVisible = ref(false)
const qrcodeUrl = ref('')
function getCode() {
  miniQrcode(commitForm.value).then(res => {
    qrcodeUrl.value = res.result
    qrcodeVisible.value = true
  })
}

const settingVisible = ref(false)
function handleClose3() {
  initCommitForm()
  settingVisible.value = false
}
function closeDialog3() {
  initCommitForm()
  settingVisible.value = false
}
function setting(row) {
  commitForm.value.appId = row.appId
  settingVisible.value = true
  privacySetting(row.appId).then(res => {

  })
}

const avatarVisible = ref(false)
function setAvatar() {
  avatarVisible.value = true
}
function handleClose4() {
  initCommitForm()
  fileList4.value = []
  avatarVisible.value = false
}
function closeDialog4() {
  initCommitForm()
  fileList4.value = []
  avatarVisible.value = false
}
const fileList4 = ref([])
function upload4(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      commitForm.value.headImage = res.result
      yyglForm.value.validateField('headImage')
    } else {
      fileList4.value.pop()
    }
  })
}
// const uploadSuccess4 = (res) => {
//   if (res.code != 200) {
//     ElMessage({
//       type: 'warning',
//       message: res.message
//     })
//     fileList4.value.pop()
//     return
//   }
//   commitForm.value.headImage = res.result
//   yyglForm.value.validateField('headImage')
// }
function enterDialog4() {
  yyglForm.value.validate(async (valid) => {
    if (valid) {
      let res = await setHeadImage(commitForm.value)
      if (res.code == 200) {
        if (res.result.errcode != 0) {
          ElMessage({
            type: 'error',
            message: errMap[res.result.errcode] || res.result.errmsg
          })
          return
        } else {
          ElMessage({
            type: 'success',
            message: '设置成功'
          })
          initCommitForm()
          fileList4.value = []
          avatarVisible.value = false
          getTableData()
        }
      }
    }
  })
}
const nameVisible = ref(false)
function setName() {
  nameVisible.value = true
}
function handleClose5() {
  initCommitForm()
  nameVisible.value = false
}
function closeDialog5() {
  initCommitForm()
  nameVisible.value = false
}
function enterDialog5() {
  yyglForm.value.validate(async (valid) => {
    if (valid) {
      let res = await setNickname(commitForm.value)
      if (res.code == 200) {
        if (res.result.errcode != 0) {
          ElMessage({
            type: 'error',
            message: errMap[res.result.errcode] || res.result.errmsg
          })
          return
        } else {
          ElMessage({
            type: 'success',
            message: '设置成功'
          })
          initCommitForm()
          nameVisible.value = false
        }
      }
    }
  })
}
const domainVisible = ref(false)
function setDomian() {
  domainVisible.value = true
}
function handleClose6() {
  initCommitForm()
  domainVisible.value = false
}
function closeDialog6() {
  initCommitForm()
  domainVisible.value = false
}
const domainObj = ref({
  action: 'add',
  downloadDomain: '',
  requestDomain: '',
  tcpDomain: '',
  udpDomain: '',
  uploadDomain: '',
  wsRequestDomain: ''
})
function enterDialog6() {
  yyglForm.value.validate(async (valid) => {
    if (valid) {
      commitForm.value.action = domainObj.value.action
      commitForm.value.downloadDomain = domainObj.value.downloadDomain.split(';')
      commitForm.value.requestDomain = domainObj.value.requestDomain.split(';')
      commitForm.value.tcpDomain = domainObj.value.tcpDomain.split(';')
      commitForm.value.udpDomain = domainObj.value.udpDomain.split(';')
      commitForm.value.uploadDomain = domainObj.value.uploadDomain.split(';')
      commitForm.value.wsRequestDomain = domainObj.value.wsRequestDomain.split(';')
      let res = await modifyDomain(commitForm.value)
      if (res.code == 200) {
        if (res.result.errcode != 0) {
          ElMessage({
            type: 'error',
            message: errMap[res.result.errcode] || res.result.errmsg
          })
          return
        } else {
          ElMessage({
            type: 'success',
            message: '设置成功'
          })
          initCommitForm()
          domainVisible.value = false
        }
      }
    }
  })
}
function publish() {
  miniRelease(commitForm.value.appId).then(res => {
    if (res.code == 200) {
      if (res.result.errcode != 0) {
        ElMessage({
          type: 'error',
          message: errMap[res.result.errcode] || res.result.errmsg
        })
        return
      } else {
        ElMessage({
          type: 'success',
          message: '发布成功'
        })
        initCommitForm()
        commitDialog.value = false
      }
    }
  })
}
const shArr = ['审核成功', '审核被拒绝', '审核中', '已撤回', '审核延后']
function shStatus() {
  auditStatus(commitForm.value).then(res => {
    console.log(shArr[res.result.status], 'shArr[res.result.status]')
    ElMessage({
      type: 'info',
      message: '当前状态: ' + shArr[res.result.status]
    })
  })
}
const cascader2 = ref(null)
const searchAreaChange2 = (val, selectedData) => {
  let checkedNodes = cascader2.value.getCheckedNodes().filter(item => item.pathValues.length > 1)
  console.log(checkedNodes, 'checkedNodes')
  baForm.value.icp_applets.base_info.service_content_types = checkedNodes.map(item => item.value)
}
const fileList1 = ref([])
function upload1(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, certificateType: String(baForm.value.certificate_type2), icpOrderField: 'icp_applets.principal_info.certificate_photo_back' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_applets.principal_info.certificate_photo_back = res2.result
          yyglForm.value.validateField('certificate_photo_back2')
        } else {
          fileList1.value.pop()
        }
      })
    } else {
      fileList1.value.pop()
    }
  })
}
const fileList2 = ref([])

function upload2(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, certificateType: String(baForm.value.certificate_type2), icpOrderField: 'icp_applets.principal_info.certificate_photo_front' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_applets.principal_info.certificate_photo_front = res2.result
          yyglForm.value.validateField('certificate_photo_front2')
        } else {
          fileList2.value.pop()
        }
      })
    } else {
      fileList2.value.pop()
    }
  })
}

const progress = ref(0)
function rzProgress(val) {
  progress.value = val
  //formInfo.value = JSON.parse(JSON.stringify(rzForm.value))
  //console.log(formInfo.value, 'formInfo.value')
  // if (formInfo.value.appId) {
  //   rzForm.value = JSON.parse(JSON.stringify(formInfo.value))
  // }
}
const areaList = ref([])
const certificate_types = ref([])
const nrlxList = ref([])
function auth(row) {
  rzForm.value.appId = row.appId
  rzVisible.value = true
}

function changeArea(val) {
  if (val && val.length > 0) {
    baForm.value.icp_subject.base_info.province = String(val[0])
    baForm.value.icp_subject.base_info.city = String(val[1])
    baForm.value.icp_subject.base_info.district = String(val[2])
  }
}
const fileList3 = ref([])
const fileList6 = ref([])
const fileList7 = ref([])
const fileList8 = ref([])
const fileList9 = ref([])
const fileList10 = ref([])
const fileList11 = ref([])
const fileList12 = ref([])
const fileList13 = ref([])
const fileList14 = ref([])
const fileList15 = ref([])
const fileList16 = ref([])
const fileList17 = ref([])
const fileList18 = ref([])
const fileList19 = ref([])
const fileList21 = ref([])
function upload21(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, certificateType: String(baForm.value.certificate_type1), icpOrderField: 'icp_subject.organize_info.certificate_photo' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_subject.organize_info.certificate_photo = res2.result
          yyglForm.value.validateField('certificate_photo1')
        } else {
          fileList21.value.pop()
        }
      })
    } else {
      fileList21.value.pop()
    }
  })
}
function upload3(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, certificateType: String(baForm.value.certificate_type11), icpOrderField: 'icp_subject.principal_info.certificate_photo_front' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_subject.principal_info.certificate_photo_front = res2.result
          yyglForm.value.validateField('certificate_photo_front1')
        } else {
          fileList3.value.pop()
        }
      })
    } else {
      fileList3.value.pop()
    }
  })
}
function upload6(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, certificateType: String(baForm.value.certificate_type11), icpOrderField: 'icp_subject.principal_info.certificate_photo_back' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_subject.principal_info.certificate_photo_back = res2.result
          yyglForm.value.validateField('certificate_photo_back1')
        } else {
          fileList6.value.pop()
        }
      })
    } else {
      fileList6.value.pop()
    }
  })
}
function upload7(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, certificateType: String(baForm.value.type2), icpOrderField: 'icp_applets.base_info.nrlx_details[0].media' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_applets.base_info.nrlx_details[0].media = res2.result
          yyglForm.value.validateField('media2')
        } else {
          fileList7.value.pop()
        }
      })
    } else {
      fileList7.value.pop()
    }
  })
}
function upload8(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, icpOrderField: 'icp_materials.commitment_letter' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_materials.commitment_letter = [res2.result]
        } else {
          fileList8.value.pop()
        }
      })
    } else {
      fileList8.value.pop()
    }
  })
}
function upload9(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, icpOrderField: 'icp_materials.business_name_change_letter' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_materials.business_name_change_letter = [res2.result]
        } else {
          fileList9.value.pop()
        }
      })
    } else {
      fileList9.value.pop()
    }
  })
}
function upload10(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, icpOrderField: 'icp_materials.party_building_confirmation_letter' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_materials.party_building_confirmation_letter = [res2.result]
        } else {
          fileList10.value.pop()
        }
      })
    } else {
      fileList10.value.pop()
    }
  })
}
function upload11(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, icpOrderField: 'icp_materials.promise_video' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_materials.promise_video = [res2.result]
        } else {
          fileList11.value.pop()
        }
      })
    } else {
      fileList11.value.pop()
    }
  })
}
function upload12(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, icpOrderField: 'icp_materials.authenticity_responsibility_letter' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_materials.authenticity_responsibility_letter = [res2.result]
        } else {
          fileList12.value.pop()
        }
      })
    } else {
      fileList12.value.pop()
    }
  })
}
function upload13(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, icpOrderField: 'icp_materials.authenticity_commitment_letter' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_materials.authenticity_commitment_letter = [res2.result]
        } else {
          fileList13.value.pop()
        }
      })
    } else {
      fileList13.value.pop()
    }
  })
}
function upload14(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, icpOrderField: 'icp_materials.website_construction_proposal' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_materials.website_construction_proposal = [res2.result]
        } else {
          fileList14.value.pop()
        }
      })
    } else {
      fileList14.value.pop()
    }
  })
}

function handleRemove15(file, fileList) {
  const index = fileList15.value.findIndex(f => f.uid === file.uid);
  baForm.value.icp_materials.subject_other_materials.splice(index, 1)
}
function upload15(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, icpOrderField: 'icp_materials.subject_other_materials' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_materials.subject_other_materials.push(res2.result)
        } else {
          fileList15.value.pop()
        }
      })
    } else {
      fileList15.value.pop()
    }
  })
}
function upload16(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, icpOrderField: 'icp_materials.applets_other_materials' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_materials.applets_other_materials.push(res2.result)
        } else {
          fileList16.value.pop()
        }
      })
    } else {
      fileList16.value.pop()
    }
  })
}
function handleRemove16(file, fileList) {
  const index = fileList16.value.findIndex(f => f.uid === file.uid);
  baForm.value.icp_materials.applets_other_materials.splice(index, 1)
}
function upload17(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      icpUpload({ appId: baForm.value.appId, fileUrl: res.result, icpOrderField: 'icp_materials.holding_certificate_photo' }).then(res2 => {
        if (res2.code == 200) {
          baForm.value.icp_materials.holding_certificate_photo = [res2.result]
        } else {
          fileList17.value.pop()
        }
      })
    } else {
      fileList17.value.pop()
    }
  })
}

function upload18(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      mediaUpload({ appId: rzForm.value.appId, fileUrl: res.result }).then(res2 => {
        if (res2.code == 200) {
          rzForm.value.auth_data.qualification_other.push(res2.result)
        } else {
          fileList18.value.pop()
        }
      })
    } else {
      fileList18.value.pop()
    }
  })
}

function handleRemove18(file, fileList) {
  const index = fileList18.value.findIndex(f => f.uid === file.uid);
  rzForm.value.auth_data.qualification_other.splice(index, 1)
}
function upload19(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      mediaUpload({ appId: rzForm.value.appId, fileUrl: res.result }).then(res2 => {
        if (res2.code == 200) {
          rzForm.value.auth_data.account_supplemental.push(res2.result)
        } else {
          fileList19.value.pop()
        }
      })
    } else {
      fileList19.value.pop()
    }
  })
}
function handleRemove19(file, fileList) {
  const index = fileList19.value.findIndex(f => f.uid === file.uid);
  rzForm.value.auth_data.account_supplemental.splice(index, 1)
}

const fileList22 = ref([])
function upload22(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      mediaUpload({ appId: commitForm.value.appId, fileUrl: res.result }).then(res2 => {
        if (res2.code == 200) {
          //rzForm.value.auth_data.qualification_other.push(res2.result)
          commitForm.value.categories[0].certicates.push({
            value: res2.result,
            key: qualifyName.value
          })
          yyglForm.value.validateField('certicates')
        } else {
          fileList22.value.pop()
        }
      })
    } else {
      fileList22.value.pop()
    }
  })
}
function handleRemove22(file) {
  const index = fileList22.value.findIndex(f => f.uid === file.uid);
  commitForm.value.categories[0].certicates.splice(index, 1)
}

const mbData = ref([])
const mbVisible = ref(false)
function addTemplate() {
  raftList().then(res => {
    mbData.value = res.result.draft_list
    mbVisible.value = true
  })
}
function handleClose8() {
  mbVisible.value = false
}
function closeDialog8() {
  mbVisible.value = false
}
function enterDialog8() {
  if (!draftId.value && draftId.value != 0) {
    ElMessage({
      type: 'info',
      message: '请选择草稿'
    })
    return
  }
  addToTemplate(draftId.value).then(res => {
    if (res.code == 200) {
      if (res.result.errcode != 0) {
        ElMessage({
          type: 'error',
          message: errMap[res.result.errcode] || res.result.errmsg
        })
        return
      } else {
        ElMessage({
          type: 'success',
          message: '添加成功'
        })
        mbTable.value.clearSelection();
        mbVisible.value = false
      }
    }
  })
}
const mbTable = ref(null)
const draftId = ref('')
function selectMb(selection, row) {
  mbTable.value.clearSelection();
  if (selection.length == 0) return;
  mbTable.value.toggleRowSelection(row, true);
  draftId.value = row.draft_id
}

function bindAccount() {
  openBind(commitForm.value.appId).then(res => {
    if (res.code == 200) {
      if (res.result.errcode != 0) {
        ElMessage({
          type: 'error',
          message: errMap[res.result.errcode] || res.result.errmsg
        })
        return
      } else {
        ElMessage({
          type: 'success',
          message: '绑定成功'
        })
      }
    }
  })
}
function getRzStatus(val) {
  const arr = ['未认证备案', '认证备案中', '认证备案通过', '认证备案未通过', '认证已过期']
  return arr[val]
}
const baInfo = ref({
  // procedure_status:25,
  // orderid:123456,
  // refill_reason:'小程序认证审核单被驳回（procedure_status 为 18）时有效',
  // fail_reason	:'小程序认证审核最终失败的原因（procedure_status 为 20）时有效',
  // icp_audit:{
  //   hints:[{
  //     errcode:1,
  //     err_field:'icp_subject.principal_info.certificate_photo_front',
  //     errmsg:'缺少必填字段'
  //   }],
  //   audit_data:[{
  //     key_name:'审核不通过的字段中文名',
  //     error:'字段不通过的原因',
  //     suggest:'修改建议'
  //   }],
  //   sms_verify_status:1
  // }
})
const rzInfo = ref({})
const rzProgressVisible = ref(false)
function seeProce(row) {
  authQuery(row.appId).then(res => {
    if (res.code == 200) {
      rzProgressVisible.value = true
      rzInfo.value = res.result
    }
  })
}
function handleClose13() {
  rzProgressVisible.value = false
}
function closeDialog13() {
  rzProgressVisible.value = false
}
const baInfoVisible = ref(false)
function handleClose9() {
  baInfoVisible.value = false
}
function getRztaskStatus(val) {
  let arr = ['初始状态', '任务超时, 24小时内有效', '用户授权拒绝', '用户授权同意', '发起人脸流程', '人脸认证失败', '人脸认证ok', '人脸认证后，已经提交手机号码下发验证码', '手机验证失败', '手机验证成功', '', '创建认证审核单失败', '创建认证审核审核单成功', '', '验证失败', '等待支付']
  return arr[val]
}
function getRzApplyStatus(val) {
  let arr = ['审核单不存在', '待支付', '审核中', '打回重填', '认证通过', '认证最终失败（不能再修改）']
  return arr[val]
}
function getProStatus(val) {
  const obj = {
    2: '平台审核中',
    3: '平台审核驳回',
    4: '管局审核中',
    5: '管局审核驳回',
    6: '已备案',
    1024: '未备案',
    1025: '未备案 && 小程序信息未填',
    1026: '未备案 && 小程序类目未填',
    1027: '未备案 && 小程序信息未填 && 小程序类目未填',
    1028: '未备案 && 小程序未认证',
    1029: '未备案 && 小程序信息未填 && 小程序未认证',
    1030: '未备案 && 小程序类目未填 && 小程序未认证',
    1031: '未备案 && 小程序信息未填 && 小程序类目未填 && 小程序未认证'
  }
  return obj[val]
}
function getSmsStatus(val) {
  let arr = ['', '等待核验中', '核验完成', '核验超时']
  return arr[val]
}
const baVisible = ref(false)
const serviceContentTypes = ref([])
const contentTypeArr = ref([])
function ba(row) {
  baForm.value.appId = row.appId
  districtCode({ appId: row.appId }).then(res => {
    areaList.value = res.result.items
  })
  certificateTypes({ appId: row.appId }).then(res => {
    certificate_types.value = res.result.items
  })
  allCategories({ appId: row.appId }).then(res => {
    categoryArr.value = res.result
  })
  nrlxTypes({ appId: row.appId }).then(res => {
    nrlxList.value = res.result.items
  })
  contentTypes({ appId: row.appId }).then(res => {
    let arr = JSON.parse(JSON.stringify(res.result.items))
    contentTypeArr.value = arr.filter(item => item.parent_type == 0)
    contentTypeArr.value.forEach(m => {
      m.children = []
      arr.forEach(item => {
        if (m.type == item.parent_type) {
          m.children.push(item)
        }
      })
    })
    console.log(contentTypeArr.value, 'contentTypeArr.value')
  })
  baVisible.value = true
}
function arrayToTree(items) {
  console.log(items, 'items')
  const rootItems = [];
  const lookup = {};
  for (const item of items) {
    const itemId = item.type;
    lookup[itemId] = item;
    console.log(lookup, 'lookup', item.parent_type)
    const parentId = item.parent_type;
    if (parentId === 0) {
      rootItems.push(item);
      continue;
    }
    const parent = lookup[parentId];
    console.log(parent, 'ccccc')
    if (parent) {

      if (!parent.children) {
        parent.children = [];
      }
      parent.children.push(item);
    }
  }
  return rootItems;
}
function handleClose10() {
  baVisible.value = false
  initBaForm()
}
function closeDialog10() {
  baVisible.value = false
  initBaForm()
}
const fileList20 = ref([])
function upload20(params) {
  fileUpload({ file: params.file }).then(res => {
    if (res.code == 200) {
      mediaUpload({ appId: rzForm.value.appId, fileUrl: res.result }).then(res2 => {
        if (res2.code == 200) {
          rzForm.value.auth_data.qualification = res2.result
          yyglForm.value.validateField('qualification')
        } else {
          fileList20.value.pop()
        }
      })
    } else {
      fileList20.value.pop()
    }
  })
}
const lmVisible = ref(false)
const allCategoryArr = ref([])
function showLm() {
  allCategories({ appId: commitForm.value.appId }).then(res => {
    allCategoryArr.value = res.result
    lmVisible.value = true
  })
}
const cascader3 = ref(null)
const qualifyUrl = ref('')
const qualifyName = ref('')
const allCateChange = (val, selectedData) => {
  let checkedNodes = cascader3.value.getCheckedNodes().filter(item => item.pathValues.length > 1)
  console.log(checkedNodes[0].data, 'checkedNodes')
  if (checkedNodes[0].data.sensitiveType == 1) {
    qualifyName.value = checkedNodes[0].data.qualifyName
    qualifyUrl.value = checkedNodes[0].data.qualifyUrl
  } else {
    qualifyName.value = ''
    qualifyUrl.value = ''
  }
  commitForm.value.categories = checkedNodes.map(item => {
    return {
      first: item.pathValues[0],
      second: item.pathValues[1],
      certicates: [

      ]
    }
  })
}

function handleClose11() {
  qualifyName.value = ''
  qualifyUrl.value = ''
  fileList22.value = []
  lmVisible.value = false
}

function closeDialog11() {
  qualifyName.value = ''
  qualifyUrl.value = ''
  lmVisible.value = false
}

function enterDialog11() {
  yyglForm.value.validate(async (valid) => {
    if (valid) {
      let res = await addCategories(commitForm.value)
      if (res.code == 200) {
        if (res.result.errcode != 0) {
          ElMessage({
            type: 'error',
            message: errMap[res.result.errcode] || res.result.errmsg
          })
          return
        } else {
          ElMessage({
            type: 'success',
            message: '类目添加成功'
          })
          initCommitForm()
          lmVisible.value = false
        }
      }
    }
  })
}
const descVisible = ref(false)
function setDecs() {
  descVisible.value = true
}
function handleClose12() {
  initCommitForm()
  descVisible.value = false
}
function closeDialog12() {
  initCommitForm()
  descVisible.value = false
}
function enterDialog12() {
  yyglForm.value.validate(async (valid) => {
    if (valid) {
      let res = await setSignature(commitForm.value)
      if (res.code == 200) {
        if (res.result.errcode != 0) {
          ElMessage({
            type: 'error',
            message: errMap[res.result.errcode] || res.result.errmsg
          })
          return
        } else {
          ElMessage({
            type: 'success',
            message: '设置成功'
          })
          initCommitForm()
          descVisible.value = false
        }
      }
    }
  })
}
const link = ref('')
function getLink() {
  authLink().then(res => {
    link.value = res.result
  })
}
function setPrivacy() {
  privacySetting(commitForm.value.appId).then(res => {
    if (res.code == 200) {
      if (res.result.errcode != 0) {
        ElMessage({
          type: 'error',
          message: errMap[res.result.errcode] || res.result.errmsg
        })
        return
      } else {
        ElMessage({
          type: 'success',
          message: '设置成功'
        })
      }
    }
  })
}
function startFace() {
  verifyTask(baForm.value.appId).then(res => {
    if (res.code == 200) {
      if (res.result.errcode != 0) {
        ElMessage({
          type: 'error',
          message: errMap[res.result.errcode] || res.result.errmsg
        })
        return
      } else {
        ElMessage({
          type: 'success',
          message: '发起成功'
        })
      }
    }
  })
}
function baProce(row) {
  icpQuery(row.appId).then(res => {
    console.log(res, 'crjkkk')
    if (res.code == 200) {
      if (res.result.errcode != 0) {
        ElMessage({
          type: 'error',
          message: errMap[res.result.errcode] || res.result.errmsg
        })
        return
      } else {
        baInfo.value = res.result.info
        baInfoVisible.value = true
      }
    }
  })
}
</script>

<style lang="scss">
.table-style {
  .el-table-column--selection.is-leaf .el-checkbox {
    display: none;
  }
}

.popper-select {
  li[aria-haspopup="true"] {
    .el-checkbox {
      display: none;
    }
  }
}

.row {
  display: flex;
  margin-bottom: 10px;

  .label {
    width: 200px;
    text-align: right;
    margin-right: 8px;
  }

  .label2 {
    width: 130px;
    text-align: left;
    margin-right: 8px;
  }

  .value {}
}

.section-title {
  font-weight: bold;
  font-size: 20px;
  line-height: 33px;
  padding: 8px 0 4px 14px;
  color: #4E7DFD;
  border-bottom: 1px solid #E7ECF1;
  position: relative;
  margin-bottom: 20px;
}

.section-title:before {
  content: '';
  position: absolute;
  top: 17px;
  left: 0;
  width: 6px;
  height: 14px;
  border-radius: 3px;
  background: #4E7DFD;
}
</style>
